import HomePage from "@pages/home";
import LoginPage from '@pages/login'
import MainLayout from "@shared/mainLayout";
import Question from "@pages/question";
import Video from "@pages/video";
import Mine from "@pages/mine";
import Personal from "@pages/personal";
import AuthRoute from "@router/authRoute";
import Chat from "@pages/chat";

import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { Navigate } from "react-router-dom";
import Search from "@pages/search";
import SearchResult from "@pages/searchResult";



export const router = createBrowserRouter([
  {
    path: "/",
    element: <MainLayout />,
    children: [
      {
        path: "",
        element: <Navigate to="/1" />,
      },
      {
        path: ":cid",
        element: <HomePage />,
      },
      {
        path: "question",
        element: <Question />,
      },
      {
        path: "video",
        element: <Video />,
      },
      {
        path: "mine",
        element: (
          <AuthRoute>
            <Mine />
          </AuthRoute>

        ),
      },
      {
        path: "/private",
        element: <AuthRoute />,
        children: [
          {
            path: "personal",
            element: <Personal />,
            handle: {
              meta: {
                showFooter: false
              }
            }
          },
          {
            path: "chat",
            element: <Chat />,
            handle: {
              meta: {
                showFooter: false
              }
            }
          }

        ],
      },


    ],
  },
  {
    path: "/login",
    element: <LoginPage />,
  },
  {
    path: "/search",
    element: <Search />
  },
  {
    path: "/result/:key",
    element: <SearchResult />
  },
]);

export default function AppRouter() {
  return <RouterProvider router={router} />;
}